package com.core.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.system.service.IImMessageRecordService;
import com.pojo.req.im.ImRecordReq;
import com.pojo.req.im.ImRecordResp;
import com.utility.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 聊天记录
 * @author Huawei
 * @date 2023-10-23 14:19
 */
@RestController
@RequestMapping("/api/system/im")
public class IMRecordController {

    @Autowired
    private IImMessageRecordService imRecordService;

    @PostMapping("/record/page")
    public Result recordPage(@RequestBody @Validated ImRecordReq imRecordReq){
        Page<ImRecordResp> page = imRecordService.page(imRecordReq);
        return Result.returnCodeSuccess(page);
    }

    @PostMapping("read")
    public Result read(@RequestBody @Validated ImRecordReq imRecordReq){
        imRecordService.read(imRecordReq);
        return Result.returnCodeSuccess();
    }
}
